package com.app.TCES.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.app.TCES.domain.Class;
import com.app.TCES.domain.Class_Course;
import com.app.TCES.domain.Course;
import com.app.TCES.domain.Department;
import com.app.TCES.domain.Teacher_Course;
import com.app.TCES.service.A_Class_CourseService;

@Controller
public class A_Class_CourseController {

	@Autowired
	A_Class_CourseService a_Class_CourseService;
	
	
	//查询所有班级课程
	@ResponseBody
	@RequestMapping("/selectClass_Course_All")
	public Map<String, Object> selectClass_Course(){
		List<Class_Course> list = a_Class_CourseService.selectClass_Courses();
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		map.put("status", 200);
		map.put("tol", 1);
		map.put("message", "查询成功");
		return map;
	}
	
	//查询院系信息
	@ResponseBody
	@RequestMapping("/selectDpet")
	public List<Department> selectDept(){
		List<Department> list = a_Class_CourseService.selectDept();
		return list;
		
	}
	
	
	//查询班级信息
	@ResponseBody
	@RequestMapping("/CC_selectClass")
	public List<Class> selectClass(int deptId){
		List<Class> list = a_Class_CourseService.selectClasses(deptId);
		return list;
	}
	
	//查询课程信息
	@ResponseBody
	@RequestMapping("/CC_selectCourse")
	public List<Course> selectCourses(){
		List<Course> list = a_Class_CourseService.selectCourses();
		return list;
	}
	
	//添加班级课程
	@ResponseBody
	@RequestMapping("/CC_insert")
	public Map<String , String> insert(int classId,int courseId,int tchId){
		String a = a_Class_CourseService.insertClass_Course(classId,courseId,tchId);
		Map<String, String> map = new HashMap<String, String>();
		map.put("msg", a);
		return map;
	}
	
	//删除信息
	@ResponseBody
	@RequestMapping("/delete")
	public Map<String , String> delete(int classId,int courseId,int tchId){
		
		String a = a_Class_CourseService.delete(classId, courseId, tchId);
	
		Map<String , String > map = new HashMap<String, String>();
		map.put("msg", a);
		return map;
	}
	
	//通过院系和课程查相应的教师
	@ResponseBody
	@RequestMapping("/selectC_T")
	public List<Teacher_Course> selectC_T(int courseId,int deptId){
		
		List<Teacher_Course> list = a_Class_CourseService.selectC_T(courseId,deptId);
		return list;
	}
	
	
	//查询班级信息(条件:deptName)
	@ResponseBody
	@RequestMapping("/CC_selectClass1")
	public List<Class> selectClass1(String deptName){
		List<Class> list = a_Class_CourseService.selectClass(deptName);
		return list;
	}
	
	//点击院系按钮查找信息(条件:deptName)
	@ResponseBody
	@RequestMapping("/CC_selectMsgBy_deptName")
	public Map<String, Object> selectMsgBy_deptName(String deptName){
		
		List<Class_Course> list = a_Class_CourseService.selectMsgBy_deptName(deptName);
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("tol", 1);
		map.put("status", 200);
		map.put("massage", "查询成功");
		map.put("list", list);
		
		return map;
	}
	
	//点击班级按钮查找信息(条件:className)
	@ResponseBody
	@RequestMapping("/CC_selectMsgBy_className")
	public Map<String, Object> selectMsgBy_className(String className,String deptName){
		List<Class_Course> list = a_Class_CourseService.selectMsgBy_className(className,deptName);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("tol", 1);
		map.put("status", 200);
		map.put("massage", "查询成功");
		map.put("list", list);
		
		return map;
	}
	
	
}
